package models

import "time"

type PostStats struct {
	PostID          int64     `db:"post_id" json:"post_id"`
	ViewCount       int64     `db:"view_count" json:"view_count"`
	LikeCount       int64     `db:"like_count" json:"like_count"`
	CollectCount    int64     `db:"collect_count" json:"collect_count"`
	CommentCount    int64     `db:"comment_count" json:"comment_count"`
	LastViewedAt    time.Time `db:"last_viewed_at" json:"last_viewed_at"`
	LastLikedAt     time.Time `db:"last_liked_at" json:"last_liked_at"`
	LastCollectedAt time.Time `db:"last_collected_at" json:"last_collected_at"`
	LastCommentedAt time.Time `db:"last_commented_at" json:"last_commented_at"`
	CreatedAt       time.Time `db:"created_at" json:"created_at"`
	UpdatedAt       time.Time `db:"updated_at" json:"updated_at"`
}

// 定义1970-01-01常量
var ZeroTime = time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC)

// 判断时间是否是初始值
func (s *PostStats) IsZeroTime(t time.Time) bool {
	return t == ZeroTime || t.IsZero()
}

// 评论统计更新参数
type CommentStatsUpdate struct {
	PostID int64 `json:"post_id" binding:"required"`
	Count  int   `json:"count" binding:"required,min=1"`
}
